﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

/// <summary>
///CheckListEditShow 的摘要说明
/// </summary>
public class CheckListEditShow:BaseEditShowField
{
	public CheckListEditShow()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public override IEnumerable<Control> GetThisTypeControl(ConfigColumns cCol, string value, bool isEdit)
    {
        Literal ctrl = new Literal();

        DataTable tab = DBFactory.GetConn().exeTable(cCol.EditShowSqlText);
        string html = string.Empty;
        foreach (DataRow row in tab.Rows)
        {
            html += "<input type='checkbox' name='" + cCol.ColumnName + "_EditShow' value='"+row[cCol.EditShowBindValueField].ToString()+"'";
            if (isEdit)
            {
                foreach (string str in value.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                {
                    if (str == row[cCol.EditShowBindValueField].ToString())
                    {
                        html += " checked ";
                        break;
                    }
                }
            }
            html += " />" + row[cCol.EditShowBindTextField].ToString() + "&nbsp;";
        }

        ctrl.Text = html;

        yield return ctrl;
    }
}
